package com.rayo.accesscontrollercopy.utils;

import android.content.Context;
import android.widget.Toast;

/**
 * Created by lyc-pc on 17/7/5.
 */

public class ToastUtils {
    private static Toast mToast;

    public static void showLongToast(Context context, String content) {
        if (mToast == null) {
            mToast = Toast.makeText(context, content, Toast.LENGTH_LONG);
        } else {
            mToast.setText(content);
            mToast.setDuration(Toast.LENGTH_LONG);
        }
        mToast.show();
    }

    public static void showShortToast(Context context, String content) {
        if (mToast == null) {
            mToast = Toast.makeText(context, content, Toast.LENGTH_SHORT);
        } else {
            cancel();
            mToast = Toast.makeText(context, content, Toast.LENGTH_SHORT);
        }
        mToast.show();
    }

    public static void cancel() {
        if (mToast != null) {
            mToast.cancel();
            mToast=null;
        }
    }
}

